package com.minhua.jijiehao2.view;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.widget.RelativeLayout;

import com.minhua.jijiehao2.R;
import com.minhua.jijiehao2.base.adapter.ViewHolder;
import com.minhua.jijiehao2.bean.AccountBean;

/**
 * @author moo
 * @date 2017/12/1.
 * @describe
 */

public class AccountDetailDialog extends Dialog {
    private ViewHolder mViewHolder;

    public AccountDetailDialog(@NonNull Context context) {
        super(context);
        initView();
    }

    private void initView() {
        mViewHolder = ViewHolder.get(getContext(), null, null, R.layout.layout_dialog_account_detail, 0);
        getWindow().setGravity(Gravity.CENTER);
        getWindow().setBackgroundDrawable(new ColorDrawable(0));
        setContentView(mViewHolder.getConvertView(), new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
        setCanceledOnTouchOutside(false);
    }


    public void setData(AccountBean accountBean) {
        mViewHolder.setText(R.id.tvDate, accountBean.getCurrentPeriods() + "");
        mViewHolder.setText(R.id.tvCount, "" + accountBean.getAmtByMonth());
        mViewHolder.setText(R.id.tvLastDate, "" + accountBean.getLastRepayDay());
        mViewHolder.setText(R.id.tvNoticeDate, "" + accountBean.getRepayDay());
        mViewHolder.setOnClickListener(R.id.tvSure, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

}
